<!--
 * @Description:下拉框
 * @Author: Sun
 * @Date: 2019-07-01 20:05:50
 * @LastEditors: Sun
 * @LastEditTime: 2019-07-28 14:14:55
 -->
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>下拉框</title>
	<style>
		* {
			margin: 0;
			padding: 0
		}

		ul {
			list-style: none;
		}

		.all {
			width: 450px;
			height: 30px;
			background: pink;
			margin: 100px auto;
			line-height: 30px;
			text-align: center;
		}

		.all ul li {
			width: 100px;
			height: 30px;
			background: sienna;
			float: left;
			margin-right: 10px;
			position: relative;
		}

		.all ul ul {
			position: absolute;
			left: 0;
			top: 30px;
			display: none;
		}
	</style>
	<script>
		window.onload = function () {
			var list = document.getElementById("list")
			var sm = list.children[0].children
			console.log("sm")
			console.log(sm)
			for (let index = 0; index < sm.length; index++) {
				const element = sm[index];
				element.onmouseover = function () {
					show(element.children[1])
				}
				element.onmouseout = function () {
					hide(element.children[1])
				}
			}

			function show(obj) {
				obj.style.display = "block"
			}

			function hide(obj) {
				obj.style.display = "none"
			}
		}
	</script>
</head>

<body>
	<ul id="list" class="all">
		<ul>
			<li>
				下拉框1
				<ul>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
				</ul>
			</li>
			<li>
				下拉框2
				<ul>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
				</ul>
			</li>
			<li>
				下拉框3
				<ul>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
				</ul>
			</li>
			<li>
				下拉框4
				<ul>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
					<li>&1</li>
				</ul>
			</li>
		</ul>
	</ul>
</body>

</html>